package com.dp;

import java.util.List;

public class Solution29 {
    public int rob(int[] nums) {
        int pre = 0;
        int cur = nums[0];
        int res = nums[0];
        for (int i = 1; i < nums.length; i++) {
            res = Math.max(cur, pre + nums[i]);
            pre = cur;
            cur = res;
        }
        return res;
    }
}
